package com.windowes.weichang.controller.manage;

import com.windowes.weichang.common.ServerResponse;
import com.windowes.weichang.service.DistrictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/***
 *
 * @author: yangqing
 * @email: qing.yang@bangdao-tech.com
 * @createTime: 2018/5/25 下午5:42
 * @description:
 *
 **/
@RestController
@RequestMapping("district")
@Api(description = "地区相关API")
@Slf4j
public class DistrictController {


    @Autowired
    DistrictService districtService;

    @ApiOperation(value = "获取地区信息", notes = "")
    @GetMapping("item")
    public ServerResponse getItem(@RequestParam("id") Integer id) {
        return districtService.getItem(id);
    }

    @ApiOperation(value = "获取自己及集列表", notes = "默认,天津")
    @GetMapping("itemWithSubLevel")
    public ServerResponse itemWithSubLevel(@RequestParam(value = "id", defaultValue = "356") Integer id) {
        return districtService.itemWithSubLevel(id);
    }


    @ApiOperation(value = "获取子集列表", notes = "")
    @GetMapping("subList")
    public ServerResponse subList(@RequestParam(value = "id", defaultValue = "0") Integer id) {
        return districtService.subList(id);
    }

    @ApiOperation(value = "获取城市列表", notes = "")
    @GetMapping("subListLevel1")
    public ServerResponse subListLevel1() {
        return districtService.subListLevel1();
    }

    @ApiOperation(value = "获取省市区街道树形结构", notes = "速度较慢,非必要不要调用")
    @GetMapping("tree")
    public ServerResponse getTree(@RequestParam(value = "id", defaultValue = "0") Integer id) {
        return districtService.getTree(id);
    }


    @GetMapping("updateDistrict")
    public ServerResponse updateDistrict() {
        return districtService.updateDistrict();
    }

}
